package org.example.proxy.dynamicProxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

//代理对象
public class JdkProxy implements InvocationHandler {

    //目标对象
    private Object target;

    public JdkProxy(Object target){
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //执行额外的方法
        System.out.println("xxxxxxxxxxxxxxxxxxxxx");
        //执行被代理对象的方法
        return method.invoke(target, args);
    }
}
